package IO;

import java.io.File;
import java.io.IOException;

public class IODemo6 {
    public static void main(String[] args) throws IOException {
        //boolean renameTo(File dest)
        //进行文件改名，也可以视为我们平时的剪切、粘贴操作
        //剪切、粘贴 方法2
        File file1 = new File("./aaa/f1.txt");
        //跟这句关系不大File file2 = new File("./aaa/bbb/f2.txt");
        File file3 = new File("./aaa/bbb/f1.txt");
        file1.createNewFile();
        //跟这句关系不大file2.createNewFile();

        System.out.println(file1.renameTo(file3));

    }
    public static void main2(String[] args) throws IOException {
        //boolean renameTo(File dest)
        //进行文件改名，也可以视为我们平时的剪切、粘贴操作

        //剪切、粘贴 方法1
        //File dirs = new File("./");
        File file1 = new File("./aaa/bbb/ccc/old.txt");
        File file2 = new File("./aaa/new.txt");
        file1.createNewFile();
        file1.renameTo(file2);
    }
    public static void main1(String[] args) throws IOException {
        //boolean renameTo(File dest)
        //进行文件改名，也可以视为我们平时的剪切、粘贴操作

        //改名
        File oldNameFile = new File("./old.txt");
        File newNameFile = new File("./new.txt");
        oldNameFile.createNewFile();
        oldNameFile.renameTo(newNameFile);
        //newNameFile.delete();
        //oldNameFile.delete();




    }
}
